//
// Created by zhenduowang on 2020/9/10.
//
#include <stdio.h>
#include <time.h>

int main() {
    printf("Hello C World!\n");
    struct tm *systemTime, *ptm;
    time_t nowTime, newTime;
    time(&nowTime);// nowTime = time(NULL);
    ptm = gmtime (&nowTime); //建 UTC 时间
    systemTime = localtime(&nowTime);
    printf("系统日期：%d-%d-%d %d:%d:%d\n", 1900 + systemTime->tm_year, systemTime->tm_mon + 1, systemTime->tm_mday, systemTime->tm_hour, systemTime->tm_min, systemTime->tm_sec);

    ptm = systemTime;
    newTime = mktime (ptm); //得UTC时间 年月日时分秒
    printf("%s ", ctime(&newTime)); //打印出 Fri Sep 11 20:21:28 2020
    newTime = newTime + 8 * 3600; //北京时间加8小时就是 Sat Sep 12 04:21:28 2020
    printf("%s ", ctime(&newTime));
    return 0;
}